package com.macro.mall.model;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * banner_info实体类
 *
 * @author gaodx
 *
 */
@Data
@Builder
@AllArgsConstructor
public class BannerInfo implements Serializable{
	/**id*/
    @ApiModelProperty(value = "id")
	private Integer id; 
	/**根据type存放对应id*/
    @ApiModelProperty(value = "根据type存放对应id")
	private Integer sourceId; 
	/**01-课程 02-服务 03-新闻 04-广告*/
    @ApiModelProperty(value = "01-课程 02-服务 03-新闻 04-广告")
	private String sourceType; 
	/**01-首页 02-学习首页*/
    @ApiModelProperty(value = "01-首页 02-学习首页")
	private String position;
	/**1-APP 2-小程序 3-公众号*/
    @ApiModelProperty(value = "1-APP 2-小程序 3-公众号")
	private String channel; 
	/***/
    @ApiModelProperty(value = "")
	private String bannerName; 
	/**图片地址*/
    @ApiModelProperty(value = "图片地址")
	private String bannerImage; 
	/**0无效1生效*/
    @ApiModelProperty(value = "0无效1生效")
	private String status; 
	/**生效时间*/
    @ApiModelProperty(value = "生效时间")
	private Date startTime; 
	/**失效时间*/
    @ApiModelProperty(value = "失效时间")
	private Date endTime; 
	/**排序*/
    @ApiModelProperty(value = "排序")
	private String sort; 
	/**创建时间*/
    @ApiModelProperty(value = "创建时间")
	private Date createTime; 
	/**
	 * 实例化
	 */
	public BannerInfo() {
		super();
	}
	/**
	 * 实例化
	 * 
	 * @param obj
	 */

	public BannerInfo(JSONObject obj) {
		this();
		if (obj.get("id") instanceof Number) {
			this.setId(((Number) obj.get("id")).intValue());
		}
		if (obj.get("sourceId") instanceof Number) {
			this.setSourceId(((Number) obj.get("sourceId")).intValue());
		}
		if (obj.get("sourceType") instanceof String) {
			this.setSourceType((String) obj.get("sourceType"));
		}
		if (obj.get("channel") instanceof String) {
			this.setChannel((String) obj.get("channel"));
		}
		if (obj.get("bannerName") instanceof String) {
			this.setBannerName((String) obj.get("bannerName"));
		}
		if (obj.get("bannerImage") instanceof String) {
			this.setBannerImage((String) obj.get("bannerImage"));
		}
		if (obj.get("status") instanceof String) {
			this.setStatus((String) obj.get("status"));
		}
		this.setStartTime((Date) obj.get("startTime"));
		this.setEndTime((Date) obj.get("endTime"));
		if (obj.get("sort") instanceof String) {
			this.setSort((String) obj.get("sort"));
		}
		this.setCreateTime((Date) obj.get("createTime"));
	}
	
	/**
	 * 将当前对象转换为JsonObject
	 * 
	 * @return
	 */
	public JSONObject toJson() {
		JSONObject result = new JSONObject();
		if (this.getId() != null) {
			result.put("id",this.getId());
		}
		if (this.getSourceId() != null) {
			result.put("sourceId",this.getSourceId());
		}
		if (this.getSourceType() != null) {
			result.put("sourceType",this.getSourceType());
		}
		if (this.getChannel() != null) {
			result.put("channel",this.getChannel());
		}
		if (this.getBannerName() != null) {
			result.put("bannerName",this.getBannerName());
		}
		if (this.getBannerImage() != null) {
			result.put("bannerImage",this.getBannerImage());
		}
		if (this.getStatus() != null) {
			result.put("status",this.getStatus());
		}
		if (this.getStartTime() != null) {
			result.put("startTime",this.getStartTime());
		}
		if (this.getEndTime() != null) {
			result.put("endTime",this.getEndTime());
		}
		if (this.getSort() != null) {
			result.put("sort",this.getSort());
		}
		if (this.getCreateTime() != null) {
			result.put("createTime",this.getCreateTime());
		}
		return result;
	}


	@Override
	public String toString() {
		return "BannerInfo [id=" + id + " , sourceId=" + sourceId + " , sourceType=" + sourceType + " , channel=" + channel + " , bannerName=" + bannerName + " , bannerImage=" + bannerImage + " , status=" + status + " , startTime=" + startTime + " , endTime=" + endTime + " , sort=" + sort + " , createTime=" + createTime + "  ]";
	
	}
	
	
}
